#include "const.h"

//
//	FIXME
//	This function does not finalize the inheritted variables. This is a simple
//	fix. Add "char *finalized;" next to the expanded field in var_s and handle.
//	Call i_strdup() to set the finalized value and replace calls to v_expand()
//	in the inheritted variables to v_finalize()... Leave v_expand() for the root
//	variable though.
//
const char *v_finalize(var_t v) {
	static char buf[65536];
	size_t i, n;
	var_t tmp;

	buf[0] = 0;

	i = 0;
	n = sizeof(buf);

	i += i_strcat(buf, n, v_expand(v));
	n = sizeof(buf)-i;

	if ((tmp=v->i.owned)!=(var_t)0) {
		i += i_strcat(&buf[i], n, " ");
		n = sizeof(buf)-i;

		i += i_strcat(&buf[i], n, v_expand(tmp));
		n = sizeof(buf)-i;
	}

	return buf;
}
